package com.geese.module.admin.service;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.geese.common.entity.OperationLog;
import com.geese.common.entity.Role;
import com.geese.common.util.PageUtil;
import com.geese.common.vo.Page;
import com.geese.common.vo.Paginator;
import com.geese.module.admin.dao.OperationLogMapper;
import com.geese.module.admin.vo.OperationLogQuery;
import com.github.pagehelper.PageHelper;

@Service
public class OperationLogService {
	
	@Autowired
	private OperationLogMapper operationLogMapper;
	
	/**
	 * 添加操作日志
	 */
	public void save(OperationLog operationLog) {
		operationLog.setCreateTime(new Date());
		operationLogMapper.save(operationLog);
	}

	public Paginator<OperationLog> listAllByQuery(OperationLogQuery query, Page page) {
		PageHelper.startPage(page.getCurrPage(), page.getPageSize(), "create_time desc");
		List<OperationLog> logList = operationLogMapper.listAllByQuery(query);
		return PageUtil.getPage(logList);
	}


}
